home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Technotools
/
Technotools (Chestnut CD-ROM)(1993).ISO
/
lang_c
/
bisonpcb
/
main.c
< prev
next >
Wrap
C/C++ Source or Header
|
1987-09-18
|
4KB
|
146 lines
/* Top level entry point of bison,
Copyright (C) 1984, 1986 Bob Corbett and Free Software Foundation, Inc.
BISON is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY. No author or distributor accepts responsibility to anyone
for the consequences of using it or for whether it serves any
particular purpose or works at all, unless he says so in writing.
Refer to the BISON General Public License for full details.
Everyone is granted permission to copy, modify and redistribute BISON,
but only under the conditions described in the BISON General Public
License. A copy of this license is supposed to have been given to you
along with BISON so you can know your rights and responsibilities. It
should be in a file named COPYING. Among other things, the copyright
notice and this notice must be preserved on all copies.
In other words, you are welcome to use, share and improve this program.
You are forbidden to forbid anyone else to use, share and improve
what you give them. Help stamp out software-hoarding! */
/*
* Port to PC by Whit Gregg
* Nourse, Gregg & Browne, Inc.
* 1 Horizon Road
* Fort Lee, NJ 07024
*/
#include <stdio.h>
#include <stdlib.h>
#include "machine.h"
#include "func.h"
extern int lineno;
extern int verboseflag;
void
main(argc, argv) /* WG */
int argc;
char *argv[];
{
printf("\n Bison ( )");
printf("\n @\n");
printf("\n author: Bob Corbett and Richard Stallman");
printf("\n PC port: Whitfield Gregg\n");
printf("\n Microsoft C Compact model revisions : Bill Davis\n");
lineno = 0;
getargs(argc, argv);
openfiles();
/*
* read the input. Copy some parts of it to fguard, faction, ftable
* and fattrs. In file reader. The other parts are recorded in the
* grammar; see gram.h.
*/
reader();
/*
* record other info about the grammar. In files derives and
* nullable.
*/
set_derives();
set_nullable();
/*
* convert to nondeterministic finite state machine. In file LR0.
* See state.h for more info.
*/
generate_states();
/* make it deterministic. In file lalr. */
lalr();
/*
* Find and record any conflicts: places where one token of lookahead
* is not enough to disambiguate the parsing. In file conflicts.
* Currently this does not do anything to resolve them; the trivial
* form of conflict resolution that exists is done in output.
*/
initialize_conflicts();
/* print information about results, if requested. In file print. */
if (verboseflag)
verbose();
else
terse();
/* output the tables and the parser to ftable. In file output. */
output();
done(0);
}
/* functions to report errors which prevent a parser from being generated */
/* JF changed to output error message in standard format. Just like CC */
void
fatal(s) /* WG */
char *s;
{
extern char *infile;
fprintf(stderr, "\"%s\", line %d: %s\n", infile, lineno, s);
done(1);
}
/* JF changed to accept/deal with variable args. Is a real kludge since
we don't support _doprnt calls */
/*VARARGS1*/
void
fatals(fmt, x1, x2, x3, x4, x5, x6, x7, x8) /* WG */
char *fmt;
{
char buffer[200];
sprintf(buffer, fmt, x1, x2, x3, x4, x5, x6, x7, x8);
fatal(buffer);
}
void
toomany(s) /* WG */
char *s;
{
char buffer[200];
/* JF new msg */
sprintf(buffer, "limit of %d exceeded, too many %s", MAXSHORT, s);
fatal(buffer);
}
void
berror(s) /* WG */
char *s;
{
fprintf(stderr, "internal error, %s\n", s);
abort();
}